package com.lc202309;

import java.util.HashSet;
import java.util.Set;

/**
 * Description:
 *
 * @Create 2023/9/12 22:13
 * @Version 1.0
 */
public class Solution349 {
    public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> res = new HashSet<>();
        Set<Integer> nums = new HashSet<>();
        for (int j : nums1) {
            nums.add(j);
        }
        for (int i : nums2) {
            if (nums.contains(i)) {
                res.add(i);
            }
        }
        return res.stream().mapToInt(Integer::intValue).toArray();
    }
}
